package com.zzyl.serve.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zzyl.common.annotation.Excel;
import com.zzyl.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 护理任务对象 nursing_task
 *
 * @author liuyp
 * @date 2025-07-30
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "护理任务实体")
public class NursingTask extends BaseEntity {
    private static final long serialVersionUID = 1L;


    // id
    @ApiModelProperty(value = "主键ID")
    private Long id;

    // 护理员id
    @Excel(name = "护理员id")
    @ApiModelProperty(value = "护理员id")
    private String nursingId;

    // 项目id
    @Excel(name = "项目id")
    @ApiModelProperty(value = "项目id")
    private Integer projectId;

    // 护理项目名称
    @Excel(name = "护理项目名称")
    @ApiModelProperty(value = "护理项目名称")
    private String projectName;

    // 老人id
    @Excel(name = "老人id")
    @ApiModelProperty(value = "老人id")
    private Long elderId;

    // 老人姓名
    @Excel(name = "老人姓名")
    @ApiModelProperty(value = "老人姓名")
    private String elderName;

    // 床位编号
    @Excel(name = "床位编号")
    @ApiModelProperty(value = "床位编号")
    private String bedNumber;

    // 预计服务时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "预计服务时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "预计服务时间")
    private LocalDateTime estimatedServerTime;

    // 实际服务时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "实际服务时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "实际服务时间")
    private LocalDateTime realServerTime;

    // 执行记录
    @Excel(name = "执行记录")
    @ApiModelProperty(value = "执行记录")
    private String mark;

    // 取消原因
    @Excel(name = "取消原因")
    @ApiModelProperty(value = "取消原因")
    private String cancelReason;

    // 状态  1待执行 2已执行 3已关闭
    @Excel(name = "状态  1待执行 2已执行 3已关闭 ")
    @ApiModelProperty(value = "状态  1待执行 2已执行 3已关闭 ")
    private Integer status;

    // 执行图片
    @Excel(name = "执行图片")
    @ApiModelProperty(value = "执行图片")
    private String taskImage;

    /**
     * 任务类型  1护理计划外 2护理计划内
     */
    @Excel(name = "任务类型")
    private Integer taskType;

    @TableField(exist = false)
    @ApiModelProperty(value = "护理员名称")
    private List<String> nursingName;

    // 用于接收数据库查询结果的临时字段
    @JsonIgnore
    @TableField(exist = false)
    private String nursingNamesStr;

    /**
     * 获取护理员姓名列表
     *
     * @return
     */
    public List<String> getNursingName() {
        if (this.nursingName == null && this.nursingNamesStr != null && !this.nursingNamesStr.isEmpty()) {
            this.nursingName = Arrays.asList(this.nursingNamesStr.split(","));
        }
        return this.nursingName;
    }

    @TableField(exist = false)
    @ApiModelProperty(value = "护理级别名称")
    private String nursingLevelName;

    @TableField(exist = false)
    @ApiModelProperty(value = "年龄")
    private Integer age;

    @TableField(exist = false)
    @ApiModelProperty(value = "性别")
    private String sex;

    @TableField(exist = false)
    @ApiModelProperty(value = "用户名称")
    private String updater;

    @TableField(exist = false)
    @ApiModelProperty(value = "身份证")
    private String idCard;
}
